<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit - Firmware API: Utilities</title>
<link href="mt_doxygen.css" rel="stylesheet" type="text/css" />
<link href="../resources/mt_doxytabs.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.header {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12pt;
	color: #222222;
}
-->
</style>
</head>

<body>
<table width="800" border="0">
    <tr>
      <td colspan="3">
        <form method="get" action="http://www.google.com/search">
          <div align="right">
            <input type="text"   name="q" size="25"
              maxlength="255" value="" />
            <input type="submit" value="Search" />
            <input type="hidden" name="sitesearch" value="makingthings.com/ref/firmware/html" />
          </div>
        </form>
       </td>
    </tr>
    <tr>
      <td><div align="center"><a href="http://www.makingthings.com">
				<img src="../resources/logo_brown_medium.png" alt="MakingThings"
									width="200" height="78" border="0" align="middle" longdesc="http://www.makingthings.com" /></a></div></td>
				<td><div align="center" class="header">
      		Make Controller Kit <br />
          Firmware API
      </div></td>
      <td><div align="center"><a href="http://www.makezine.com">
					<img src="../resources/make_logo.png" alt="MAKE Zine" 
										width="164" height="73" border="0" align="middle" longdesc="http://www.makezine.com" /></a></div></td>
    </tr>
</table>
</body>
</html>
<!-- Generated by Doxygen 1.5.4 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>Utilities<br>
<small>
[<a class="el" href="group___r_t_o_s.html">RTOS</a>]</small>
</h1>General utilities provided by the RTOS.  
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c">Malloc</a> (int size)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Dynamically allocate memory from the heap.  <a href="#gf8ee6a74b03a39bce7c3b7d95fea303c"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___utils.html#g95923aa748602fa0330903fca05ca892">MallocWait</a> (int size, int interval)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Same as Malloc, but keeps trying until it succeeds.  <a href="#g95923aa748602fa0330903fca05ca892"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___utils.html#g6b0be54448d6ce393134400f4b22fa97">Free</a> (void *memory)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Free memory from the heap.  <a href="#g6b0be54448d6ce393134400f4b22fa97"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
General utilities provided by the RTOS. 
<p>
FreeRTOS has several options for memory management - we've chosen a default one here which is pretty sensible in most cases, but you're of course welcome to use whatever makes most sense for your application. See <a href="http://www.freertos.org/a00111.html">http://www.freertos.org/a00111.html</a> for the available options. <hr><h2>Function Documentation</h2>
<a class="anchor" name="g6b0be54448d6ce393134400f4b22fa97"></a><!-- doxytag: member="rtos.c::Free" ref="g6b0be54448d6ce393134400f4b22fa97" args="(void *memory)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Free           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>memory</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Free memory from the heap. 
<p>
Once you've allocated memory using <a class="el" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc()</a>, free it when you're done with it. It's usually a good idea to set the pointer the freed memory to NULL after you've freed it. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>memory</em>&nbsp;</td><td>A pointer to the memory created by <a class="el" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc( )</a> </td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc()</a>, <a class="el" href="group___system.html#g70856cdb0248591e1ddc44d1ca96e475" title="Returns the free size of the heap.">System_GetFreeMemory( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment">  <span class="keywordtype">char</span> *bufferPtr = <a class="code" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc</a>( 1024 ); <span class="comment">// allocate 1024 bytes of memory</span>
  <span class="comment">// ...your processing here...</span>
  <a class="code" href="group___utils.html#g6b0be54448d6ce393134400f4b22fa97" title="Free memory from the heap.">Free</a>( bufferPtr ); <span class="comment">// then free the memory when you're done with it</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00523">523</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gf8ee6a74b03a39bce7c3b7d95fea303c"></a><!-- doxytag: member="rtos.c::Malloc" ref="gf8ee6a74b03a39bce7c3b7d95fea303c" args="(int size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* Malloc           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>size</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Dynamically allocate memory from the heap. 
<p>
This is pretty much the same as a normal malloc(), but for the SAM7X. <dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the allocated memory, or NULL if the memory was not available. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___utils.html#g6b0be54448d6ce393134400f4b22fa97" title="Free memory from the heap.">Free()</a>, <a class="el" href="group___system.html#g70856cdb0248591e1ddc44d1ca96e475" title="Returns the free size of the heap.">System_GetFreeMemory( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment">  <span class="keywordtype">int</span> bufferSize = 1024;
  <span class="keywordtype">char</span> *bufferPtr = <a class="code" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc</a>( bufferSize );
  <span class="comment">// now you have a 1024 character buffer</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00472">472</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g95923aa748602fa0330903fca05ca892"></a><!-- doxytag: member="rtos.c::MallocWait" ref="g95923aa748602fa0330903fca05ca892" args="(int size, int interval)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* MallocWait           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interval</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Same as Malloc, but keeps trying until it succeeds. 
<p>
This is a convenience function that will continue to call <a class="el" href="group___utils.html#gf8ee6a74b03a39bce7c3b7d95fea303c" title="Dynamically allocate memory from the heap.">Malloc( )</a> at a given interval until it returns successfully. Once this function returns, you know you have been allocated the memory you asked for.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td>An integer specifying the amount of memory, in bytes, you want to allocate. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interval</em>&nbsp;</td><td>An integer specifying the number of milliseconds to wait between successive attempts to allocate memory. It's best to not set this too low, as it will be a bit taxing on the system. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the allocated memory, or NULL if the memory was not available. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___utils.html#g6b0be54448d6ce393134400f4b22fa97" title="Free memory from the heap.">Free()</a>, <a class="el" href="group___system.html#g70856cdb0248591e1ddc44d1ca96e475" title="Returns the free size of the heap.">System_GetFreeMemory( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment">  <span class="keywordtype">char</span> *bufferPtr = <a class="code" href="group___utils.html#g95923aa748602fa0330903fca05ca892" title="Same as Malloc, but keeps trying until it succeeds.">MallocWait</a>( 1024, 100 );
  <span class="comment">// now you have a 1024 character buffer</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00495">495</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit</title>
<style type="text/css">
<!--
.footer {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9pt;
	color: #999999;
}
-->
</style>
</head>

<body>
<hr size="1">
<div>
  <p class="footer">The Make Controller Kit is an open source project maintained by <a href="http://www.makingthings.com">MakingThings</a>.<br />
    MakingThings code is released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 license</a>.<br />
    Bug tracker, development wiki and status can be found at <a href="http://dev.makingthings.com">http://dev.makingthings.com</a>.<br />
		This document was last updated on 5 Dec 2007.
</p>
</div>
<!-- Google Analytics Code -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-769030-1";
urchinTracker();
</script>
</body>
</html>
